/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gridworld_v5;

/**
 *
 * @author Jonah
 */
public abstract class ThreadedActor implements Runnable{
    /*implementation comment*/
    ////<editor-fold defaultstate="collapsed" desc="Instanced Variables">
    protected PossibleStates actorType;
    protected Game game;
    private Board board;
    protected  Tile currentTile;
    protected boolean dead = false;
    protected long lifeSpan;
    protected long turnTime;
    protected long startTime, pauseTime;
    private boolean paused;
    
    
    //</editor-fold>
    ////<editor-fold defaultstate="collapsed" desc="Constructor">
     public ThreadedActor(Game game, Board board, Tile tile) {
        this.game = game;
        this.board = board;
        this.currentTile = tile;
        startTime = System.currentTimeMillis();
    }
    //</editor-fold>
    ////<editor-fold defaultstate="collapsed" desc="Class Methods">
    public long lifeSpanPassed(){
         return (System.currentTimeMillis() - startTime);
     }
    public PossibleStates getActorType() {
        return actorType;
    }
    public boolean isTypeOf(PossibleStates type) {
        if( actorType.equals(type)){
            return true;
        }else
            return false;
    }
    public void moveToTile(Tile tile) {
        currentTile.removeActor(this);
        currentTile.update();
        tile.addActor(this);
        currentTile = tile;
        currentTile.update();
    }
    public void killed(){
        System.out.println(actorType + ":" + this + " has been killed");
        currentTile.removeActor(this);
        game.removeActor(this);
        dead = true;
    }
    public void pause(){
        paused = true;
        pauseTime = System.currentTimeMillis();
    }
    public void unpause(){
        if (paused) {
            System.out.println(actorType + " unpaused");
            paused = false;
            System.out.println(!isPaused());
            startTime += System.currentTimeMillis() - pauseTime;
        }
    }
    public boolean isPaused(){
        return paused;
    }
    //</editor-fold>
    ////<editor-fold defaultstate="collapsed" desc="Abstract Methods">
    public abstract void checkSafeTiles();
    //@Override
    //public abstract void run();
    //</editor-fold>
    ////<editor-fold defaultstate="collapsed" desc="Interface Override Methods">
    //</editor-fold>
}
